#============================================================
#    Mouse Click
#============================================================
# - datetime: 2022-08-29 20:25:14
#============================================================

##  鼠标点击
class_name MouseClick
extends Node2D


## 鼠标左键按下
signal click_down(pos: Vector2)
## 鼠标左键抬起
signal click_up(pos: Vector2)
## 鼠标双击左键
signal double_clicked(pos: Vector2)


#============================================================
#  内置
#============================================================
func _unhandled_input(event: InputEvent) -> void:
	if event is InputEventMouseButton:
		if event.button_index == MOUSE_BUTTON_LEFT:
			if event.pressed:
				click_down.emit(get_global_mouse_position())
				if event.double_click:
					double_clicked.emit(get_global_mouse_position())
			else:
				click_up.emit(get_global_mouse_position())
	elif event is InputEventScreenTouch:
		if event.pressed:
			click_down.emit(get_global_mouse_position())
		


